package com.sfang.common.base.dingtalk;

import com.dingtalk.api.DefaultDingTalkClient;
import com.dingtalk.api.DingTalkClient;
import com.dingtalk.api.request.OapiRobotSendRequest;
import com.dingtalk.api.response.OapiRobotSendResponse;
import com.taobao.api.ApiException;

/**
 * @author locket
 * @since 2023/11/3 13:43
 */

public class DingTalkUtil {

    public static void send(String msg, String webhookUrl) throws ApiException {
        DingTalkClient client = new DefaultDingTalkClient(webhookUrl);
        OapiRobotSendRequest request = new OapiRobotSendRequest();
        request.setMsgtype("text");
        OapiRobotSendRequest.Text text = new OapiRobotSendRequest.Text();
        text.setContent(msg);
        request.setText(text);
        OapiRobotSendResponse response = client.execute(request);
    }
}
